package com.bling.action;

import java.sql.SQLException;

import javax.annotation.Resource;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.bling.action.base.BaseAction;
import com.bling.common.bean.Admin;
import com.bling.common.constant.ActionReturn;
import com.bling.common.util.RandomCode;
import com.bling.iservice.IAdminService;
/**
 * 管理员登陆界面
 * @author BLingSoft
 */
@Controller
@Scope("prototype")
public class AdminAction extends BaseAction {

	/**
	 * 跳转管理员登陆页面
	 * @return
	 */
	public String tologin(){
		String[] randomcode = RandomCode.randomCode();
		this.setCodetext(randomcode[0]);
		this.setRightcode(randomcode[1]);
		return ActionReturn.JSP;
	}
	/**
	 * 管理员登陆操作
	 * @return
	 */
	public String login(){
		Admin admin = null;
		try {
			admin = adminService.findAdminByUsername(username);
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return ActionReturn.JSP;
	}
	public void validateLogin(){
		if(null==username||username.length()<1){
			this.setErrormsg("");
		}
	}
	
	public String index(){
		return ActionReturn.JSP;
	}
	
	private static final long serialVersionUID = 2034585748524798768L;
	private String username;
	private String password;
	private String newpassword;
	private IAdminService adminService;
	public String getUsername() {
		return username;
	}
	public void setUsername(String username) {
		this.username = username;
	}
	public String getPassword() {
		return password;
	}
	public void setPassword(String password) {
		this.password = password;
	}
	public String getNewpassword() {
		return newpassword;
	}
	public void setNewpassword(String newpassword) {
		this.newpassword = newpassword;
	}
	public IAdminService getAdminService() {
		return adminService;
	}
	@Resource
	public void setAdminService(IAdminService adminService) {
		this.adminService = adminService;
	}
}
